package com.thinkcoder.Interceptor.config;

import com.thinkcoder.Interceptor.SignInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //需要拦截的请求，/**表示所有请求
        String[] addPathPatterns={"/**"};
        //不需要拦截的请求
        String[] excludePathPatterns={"/gettoken/**"};

        registry.addInterceptor(new SignInterceptor())
                .excludePathPatterns(excludePathPatterns)
                .addPathPatterns(addPathPatterns);


    }
}
